const treeToFlat = (treeList = [], flatList = [], children = 'items') => {
  if (flatList.length > 9999) {
    return []
  }
  treeList.forEach((e) => {
    flatList.push(e)
    if (e[children] && e[children].length) {
      treeToFlat(e[children], flatList, children)
    }
  })
  return flatList
}

export { treeToFlat }
